package com.clinic.entity.db;

import java.io.Serializable;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = Drug.TABLE)
public class Drug implements Serializable{

	private static final long serialVersionUID = -8926291004248810457L;
	
	public static final String TABLE = "drug";
	
	public class Columns{	
		public static final String DRUG_ID = "drugId";
		public static final String NAME = "name";
		public static final String WEIGHT = "weight";
		public static final String MINIMUM = "minimum";
		public static final String BRAND_ID = "brandId";
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = Columns.DRUG_ID)
	private long drugId;
	
	@Column(name = Columns.NAME)
	private String name;
	
	@Column(name = Columns.WEIGHT)
	private float weight;
	
	@Column(name = Columns.MINIMUM)
	private int minimum;
	
	@ManyToOne(cascade=CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinColumn(name = Columns.BRAND_ID)
	private DrugBrand brand;
	
	@OneToMany(mappedBy="drug", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
    private List<DrugStock> stocks;
	
	@OneToMany(mappedBy="drug", cascade=CascadeType.ALL, fetch = FetchType.LAZY)
    private List<DrugIssue> issues;

	public long getDrugId() {
		return drugId;
	}

	public void setDrugId(long drugId) {
		this.drugId = drugId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public float getWeight() {
		return weight;
	}

	public void setWeight(float weight) {
		this.weight = weight;
	}

	public int getMinimum() {
		return minimum;
	}

	public void setMinimum(int minimum) {
		this.minimum = minimum;
	}

	public DrugBrand getBrand() {
		return brand;
	}

	public void setBrand(DrugBrand brand) {
		this.brand = brand;
	}

	public List<DrugStock> getStocks() {
		return stocks;
	}

	public void setStocks(List<DrugStock> stocks) {
		this.stocks = stocks;
	}

	public List<DrugIssue> getIssues() {
		return issues;
	}

	public void setIssues(List<DrugIssue> issues) {
		this.issues = issues;
	}

}
